
<nav aria-label="Page navigation example" class="nav-pagination">
  <ul class="pagination">
    {% if page_obj.has_previous %}
    <li><a href="?page={{ page_obj.previous_page_number }}">Назад</a></li>
    {% else %}
    <li class="disabled"><span>Назад</span></li>
    {% endif %}
    {% for i in paginator.page_range %}
    {% if page_obj.number == i %}
    <li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li>
    {% else %}
    <li><a href="?page={{ i }}">{{ i }}</a></li>
    {% endif %}
    {% endfor %}
    {% if page_obj.has_next %}
    <li><a href="?page={{ page_obj.next_page_number }}">Далее</a></li>
    {% else %}
    <li class="disabled"><span>Далее</span></li>
    {% endif %}
  </ul>
</nav>